package com.itheima.web;

import com.itheima.dto.SetmealDto;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import com.itheima.support.PageResult;
import com.itheima.support.QueryPageBean;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Reference
    private SetmealService setmealService;

    @PostMapping("/save")
    public boolean save(@RequestBody SetmealDto setmealDto){
        return setmealService.save(setmealDto);
    }

    @GetMapping("/deleteById/{id}")
    public boolean deleteById(@PathVariable("id") Long id){
        return setmealService.deleteById(id);
    }

    @GetMapping("/findAll")
    public List<Setmeal> findAll(){

        return setmealService.findAll();
    }

    @PostMapping("/findByPage")
    public PageResult findByPage(@RequestBody QueryPageBean queryPageBean){
        return setmealService.findByPage(queryPageBean);
    }

    @GetMapping("/clearOssObject")
    public void clearOssObject() {
        setmealService.clearOssObject();
    }

}
